package main

import (
	"io"
	
	"strings"
	"fmt"
)

type rot13Reader struct {
	r io.Reader
}
func (rot rot13Reader)Read(b []byte) (int,error){//rot13Reader的方法Read
	n,err := rot.r.Read(b)
	for i:=0;i<n;i++{
		if('A' <= b[i] && b[i] <= 'Z'){
			b[i] = 'A' + (b[i]-'A'+13)%26
		}	
		if('a' <= b[i] && b[i] <= 'z'){
			b[i] = 'a' + (b[i]-'a'+13)%26
		}
	}
	return n,err
}


func main() {
	s := strings.NewReader("Lbh penpxrq gur pbqr!")//s io.Reader
	r := rot13Reader{s}

	
	
	b := make([]byte, 8)
	for {
		n, err := r.Read(b)
		fmt.Printf("n = %v err = %v b = %v\n", n, err, b)
		fmt.Printf("b[:n] = %q\n", b[:n])
		if err == io.EOF {
			break
		}
	}
}
